<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    div {
        width: 100px;
        height: 100px;
        background-color: pink;
        font-size: 16px;
    }
    
    .change {
        background-color: skyblue;
        color: #fff;
        font-size: 25px;
        margin-top: 100px;
        text-align: center;
    }
</style>

<body>
    <div class="first">文本</div>
    <script>
        var test = document.querySelector('div');
        test.onclick = function() {
            this.className = 'first change'; //会保留原先的类
        }
    </script>
</body>

</html>